package com.homwee.factory.util.view;

import com.homwee.factory.R;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.RelativeLayout;

public class FactoryMacSixView extends RelativeLayout{
	private FactoryMacWriteView mMac0;
	private FactoryMacWriteView mMac1;
	private FactoryMacWriteView mMac3;
	private FactoryMacWriteView mMac4;
	private FactoryMacWriteView mMac6;
	private FactoryMacWriteView mMac7;
	private FactoryMacWriteView mMac9;
	private FactoryMacWriteView mMac10;
	private FactoryMacWriteView mMac12;
	private FactoryMacWriteView mMac13;
	private FactoryMacWriteView mMac15;
	private FactoryMacWriteView mMac16;
	private Context mcontext;
	public FactoryMacSixView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.mcontext = context;
		initView();
		
	}
	public FactoryMacSixView(Context context) {
		super(context);
		this.mcontext = context;
		initView();
		
	}
	private void initView() {
		this.addView(inflate(mcontext,R.layout.factory_mac_six_view, null));
		mMac0 = (FactoryMacWriteView)findViewById(R.id.mac0);
		mMac1 = (FactoryMacWriteView)findViewById(R.id.mac1);
		mMac3 = (FactoryMacWriteView)findViewById(R.id.mac3);
		mMac4 = (FactoryMacWriteView)findViewById(R.id.mac4);
		mMac6 = (FactoryMacWriteView)findViewById(R.id.mac6);
		mMac7 = (FactoryMacWriteView)findViewById(R.id.mac7);
		mMac9 = (FactoryMacWriteView)findViewById(R.id.mac9);
		mMac10 = (FactoryMacWriteView)findViewById(R.id.mac10);
		mMac12 = (FactoryMacWriteView)findViewById(R.id.mac12);
		mMac13 = (FactoryMacWriteView)findViewById(R.id.mac13);
		mMac15 = (FactoryMacWriteView)findViewById(R.id.mac15);
		mMac16 = (FactoryMacWriteView)findViewById(R.id.mac16);
	}
	public void initData(String factoryMacStr) {
		Log.v("factoryMacStr","factoryMacStr.length=="+factoryMacStr.length());
	    if (factoryMacStr==null ||factoryMacStr.equals("null") ||factoryMacStr.length()<17){
	    	factoryMacStr="aa:aa:bb:cc:dd:ff";
	    }
		Log.v("factoryMacStr","factoryMacStr=="+factoryMacStr);
	    mMac0.setValue(factoryMacStr.charAt(0)+"");
		mMac1.setValue(factoryMacStr.charAt(1)+"");
		mMac3.setValue(factoryMacStr.charAt(3)+"");
		mMac4.setValue(factoryMacStr.charAt(4)+"");
		mMac6.setValue(factoryMacStr.charAt(6)+"");
		mMac7.setValue(factoryMacStr.charAt(7)+"");
		mMac9.setValue(factoryMacStr.charAt(9)+"");
		mMac10.setValue(factoryMacStr.charAt(10)+"");
		mMac12.setValue(factoryMacStr.charAt(12)+"");
		mMac13.setValue(factoryMacStr.charAt(13)+"");
		mMac15.setValue(factoryMacStr.charAt(15)+"");
		mMac16.setValue(factoryMacStr.charAt(16)+"");
		Log.v("--TAG555--","factoryMacStr=="+factoryMacStr);
	}
	public String getData() {
		mMac0.getText().toString();
		mMac1.getText().toString();
		mMac3.getText().toString();
		mMac4.getText().toString();
		mMac6.getText().toString();
		mMac7.getText().toString();
		mMac9.getText().toString();
		mMac10.getText().toString();
		mMac12.getText().toString();
		mMac13.getText().toString();
		mMac15.getText().toString();
		mMac16.getText().toString();
		return  mMac0.getText().toString()+mMac1.getText().toString()+":"+
		       mMac3.getText().toString()+mMac4.getText().toString()+":"+
		       mMac6.getText().toString()+mMac7.getText().toString()+":"+
		       mMac9.getText().toString()+mMac10.getText().toString()+":"+
		       mMac12.getText().toString()+mMac13.getText().toString()+":"+
		       mMac15.getText().toString()+mMac16.getText().toString();
		
	}
	
}
